<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;
use app\common\model\goods\Goods as GoodsModel;
use app\common\model\goods\Cate;
use app\common\model\goods\GoodsHouseStock;

/**
 * 自动接口
 */
class Goods extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 商品列表
     *
     * @param string $mobile 手机号
     * @param string $event 事件名称
     */
    public function goodslist()
    {
        $page = input('page/d',0);
        $pagesize = input('pagesize/d',10);
        $GoodsModel = new GoodsModel();
        $where = [];
        $list = $GoodsModel->where($where)
            ->limit($page*$pagesize,$pagesize)
            ->order('weigh','desc')
            ->select();
        $this->success('',$list);
    }

    /**
     * 商品详情
     *
     * @param int $goods_id 商品ID
     */
    public function goodsdetail()
    {
        $goods_id = input('goods_id/d',0);
        $GoodsModel = new GoodsModel();
        $where = [];
        $where['goods_id'] = $goods_id;
        $row = $GoodsModel->where($where)
            ->find();
        $this->success('',$row);
    }
    /**
     * 商品分类
     *
     * @param string $mobile 手机号
     * @param string $event 事件名称
     */
    public function goodscate(){
        $where = [];
        $Cate = new Cate;
        $list = $Cate->where($where)
            ->select();
        $this->success('',$list);
    }
}
